import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: '22222'
  },
  getters: {
    getUser: (state, getters) => {
      return state.user
    }
  },
  mutations: {
    setUser: (state, user) => {
      state.user = user
    }
  },
  actions: {
    yibuSetUser: ({dispatch, commit}, user) => {
      setTimeout(() => {
        commit("setUser", user);
      }, 3000)
    },
    peomiseUser: ({dispatch, commit}, user) => {
      return new Promise((resolve, reject) => {
        dispatch("yibuSetUser", user);
        resolve()
      })
    }
  },
  modules: {
  }
})
